import {get, post} from "@/components/utils/http";
import {API} from "@/common/const";


// 请求地址
let url
if (API.PORT === 80) {
    url = API.DOMAIN + "/" + API.VER
} else {
    url = API.DOMAIN + ":" + API.PORT + "/" + API.VER
}

// 图床请求地址
let imageBedReUrl = API.DOMAIN + "/" + "bed/"

/**
 * 获取文章类别
 * @returns {Promise}
 */
export function getArticleCateAPI() {
    return get(url + 'get_article_cate/')
}

/**
 * 获取文章类别
 * @returns {Promise}
 */
export function getArticleAPI() {
    return get(url + 'article/')
}


/**
 * 根据menu_code获取文章列表
 * @param menu_code
 * @returns {Promise}
 */
export function getArticleWithCateAPI(menu_code){
    return get(url + 'article_cate?' + 'category=' + menu_code)
}

/**
 * 获取motto
 * @returns {Promise}
 */
export function getMottoAPI(){
    return get(url + 'motto/')
}

/**
 * 验证码认证API
 * @param authCode
 * @returns {Promise}
 */
export function goAuthAPI(authCode){
    return post(url + 'auth/' ,{
        "authCode" : authCode
    })
}


export function getAllArticles(articleNum){
    return post(url + 'article/', {
        "article_num" : articleNum
    })
}